package com.doublefish.doublefishrobot.ui.home.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.doublefish.doublefishrobot.R;

import java.util.List;

/**
 * 作者:dugaofeng on 2025/3/19 15:53
 */

public class S5ModeCourseAdapter extends BaseQuickAdapter<S5ModeCourseAdapter.CourseInfoBean,S5ModeCourseAdapter.CourseInfoHolder> {

    private Context mContext;

    public S5ModeCourseAdapter(Context context, List<CourseInfoBean> data) {

        super(R.layout.item_course_info, data);
        mContext = context;
    }

    @Override
    protected void convert(S5ModeCourseAdapter.CourseInfoHolder helper, CourseInfoBean item) {
        if (item.getTipsText() == null) {
            helper.tipsTv.setVisibility(View.GONE);
        } else {
            helper.tipsTv.setVisibility(View.VISIBLE);
            helper.tipsTv.setText(item.getTipsText());
        }

        if (item.getImageResource() == 0) {
            helper.imageView.setVisibility(View.GONE);
        } else {
            helper.imageView.setVisibility(View.VISIBLE);
            helper.imageView.setImageResource(item.getImageResource());
        }
    }


    class CourseInfoHolder extends BaseViewHolder {
        TextView tipsTv;
        ImageView imageView;

        public CourseInfoHolder(View view) {
            super(view);

            imageView = view.findViewById(R.id.imageview);
            tipsTv = view.findViewById(R.id.textview);
        }
    }


    public static class CourseInfoBean {
        private String tipsText;
        private int ImageResource;

        public String getTipsText() {
            return tipsText;
        }

        public void setTipsText(String tipsText) {
            this.tipsText = tipsText;
        }

        public int getImageResource() {
            return ImageResource;
        }

        public void setImageResource(int imageResource) {
            ImageResource = imageResource;
        }
    }
}